package com.demo.gson;

import com.demo.gson.bean.User;
import com.google.gson.Gson;

/**
 * Created by Administrator on 2018/3/6.
 */

public class GsonTest {

    String str = "";
    User user = new User();

    public void fromJson() {
        Gson gson = new Gson();
        String jsonStr = gson.toJson(user);
        System.out.println(jsonStr);

        User user2 = gson.fromJson(jsonStr, User.class);
        System.out.println(user2.userName);
    }
}
